home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / listbo1a / ezlistbo.cls
Encoding:
Visual Basic class definition  |  1999-08-29  |  2.5 KB  |  106 lines

  1. VERSION 1.0 CLASS
  2. BEGIN
  3.   MultiUse = -1  'True
  4. END
  5. Attribute VB_Name = "EZListBox"
  6. Attribute VB_GlobalNameSpace = False
  7. Attribute VB_Creatable = True
  8. Attribute VB_PredeclaredId = False
  9. Attribute VB_Exposed = False
  10.  
  11.  
  12. Public Sub LstLoadList(List As ListBox, Filename As String)
  13.  
  14. On Error GoTo err
  15. Dim txt As String
  16. Dim FF As Integer
  17. FF = FreeFile
  18. Open Filename For Input As #FF
  19. Do While Not EOF(FF)
  20.     Line Input #FF, txt
  21.     List.AddItem txt
  22. Loop
  23. Close #FF
  24. Exit Sub
  25. err:
  26.     MsgBox "Error - " & err.Description, vbCritical, "Error " & err.Number
  27. End Sub
  28.  
  29. Public Sub LstSaveList(List As ListBox, Filename As String)
  30.  
  31. On Error GoTo err
  32. Dim FF As Integer
  33. FF = FreeFile
  34. Open Filename For Output As #FF
  35. For i = 0 To List.ListCount
  36.     Print #FF, List.List(i)
  37. Next i
  38. Close #FF
  39. Exit Sub
  40. err:
  41.     MsgBox "Error - " & err.Description, vbCritical, "Error " & err.Number
  42. End Sub
  43. Public Sub LstRemove(List As ListBox, Index As Integer)
  44.     List.RemoveItem Index
  45. End Sub
  46. Public Sub LstAdd(List As ListBox, Text As String)
  47.     List.AddItem Text
  48. End Sub
  49. Public Property Get lstCount(List As ListBox) As Integer
  50.     lstCount = List.ListCount
  51. End Property
  52.  
  53. 'THE CODE BELOW IS USED FOR COMBOBOXES ONLY
  54. 'THE CODING IS ALMOST IDENTICAL, SO I THOUGHT
  55. 'I'D PUT IT IN
  56. Public Sub CmbLoadList(Combo As ComboBox, Filename As String)
  57.  
  58. On Error GoTo err
  59. Dim txt As String
  60. Dim FF As Integer
  61. FF = FreeFile
  62. Open Filename For Input As #FF
  63. Do While Not EOF(FF)
  64.     Line Input #FF, txt
  65.     Combo.AddItem txt
  66. Loop
  67. Close #FF
  68. Combo.Text = Combo.List(0)
  69. Exit Sub
  70. err:
  71.     MsgBox "Error - " & err.Description, vbCritical, "Error " & err.Number
  72. End Sub
  73.  
  74. Public Sub CmdSaveList(Combo As ComboBox, Filename As String)
  75.  
  76. On Error GoTo err
  77. Dim FF As Integer
  78. FF = FreeFile
  79. Open Filename For Output As #FF
  80. For i = 0 To Combo.ListCount
  81.     Print #FF, Combo.List(i)
  82. Next i
  83. Close #FF
  84. Exit Sub
  85. err:
  86.     MsgBox "Error - " & err.Description, vbCritical, "Error " & err.Number
  87. End Sub
  88.  
  89. Public Sub About()
  90.  
  91.     MsgBox "EZ Listbox/Combo Class" & Chr(13) & "Copyright ⌐1999 UnpreXisten" & Chr(13) & Chr(13) & "This software is FREEWARE and may only be distributed in its original form", vbInformation, "About"
  92.     
  93. End Sub
  94.  
  95. End Sub
  96.  
  97. Public Sub CmbRemove(Combo As ComboBox, Index As Integer)
  98.     Combo.RemoveItem Index
  99. End Sub
  100. Public Sub CmbAdd(Combo As ComboBox, Text As String)
  101.     Combo.AddItem Text
  102. End Sub
  103. Public Property Get CmbCount(Combo As ComboBox) As Integer
  104.     CmbCount = Combo.ListCount
  105. End Property
  106.